<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加到购物车</title>
    <style>
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
        }

        .box {
            position: relative;
            width: 100%;
            height: 100%;
            border: 2px solid #cc726f;
            box-sizing: border-box;
        }

        .add-btn {
            width: 40px;
            height: 40px;
            border: 2px solid orange;
            border-radius: 50%;
            position: absolute;
            top: 10px;
            left: 10px;
            background: antiquewhite;
            box-sizing: border-box;
        }

        .add-btn:before, .add-btn:after {
            content: "";
            position: absolute;
            top: 50%;
            left: 10%;
            margin-top: -2px;
            width: 80%;
            height: 4px;
            background: white;
        }

        .add-btn:after {
            transform: rotate(90deg);
        }

        .shop-car {
            width: 100px;
            height: 40px;
            border: 1px solid #ff574d;
            position: absolute;
            top: 300px;
            left: 100px;
            text-align: center;
            line-height: 40px;
        }

    </style>
</head>
<body>
<div class="box">
    <div class="add-btn"></div>
    <div class="shop-car">购物车</div>
</div>
<script src="./addToCar.js"></script>
<script>
    var addBtnDom = document.querySelector(".add-btn");
    var shopCarDom = document.querySelector(".shop-car");
    addBtnDom.addEventListener("click",function () {
        //第一种方式
        controllPath(addBtnDom, shopCarDom);
        //第二种方式
        controllPath(".add-btn", ".shop-car");
    })
</script>
</body>
</html>